<?php
$project = $this->controller->project;
$customers = $this->controller->customers;
$workers = $this->controller->workers;
$developers = $this->controller->developers;
?>
<form action="" method="post">
	<table class="box">
		<tr>
			<td colspan="2" class="title">Project adatainak szerkesztése</td>
		</tr>
		<tr>
			<td>Név:</td> <td><input type="text" name="name" value="<?= $project[0]; ?>"></td>
		</tr>
		<tr>
			<td>Leírás:</td> <td><input type="text" name="descr" value="<?= $project[1]; ?>"></td>
		</tr>
		<tr>
			<td>Megrendelő:</td>
			<td>
				<select name="customer">
					<?php
						for($i=0; $i<count($customers); $i++){
							if($customers[$i][0]==$project[2]){
								print "<option value=\"".$customers[$i][0]."\" selected>".$customers[$i][1]."</option>";
							}
							else{
								print "<option value=\"".$customers[$i][0]."\">".$customers[$i][1]."</option>";
							}
						}
					?>
				</select>
			</td>
		</tr>
		<tr>
			<td>Állapot:</td>
			<td>
				<select name="status">
					<option value="1">leállított</option>
					<option value="2">folyamatban</option>
					<option value="3">befejezett</option>
				</select>
			</td>
		</tr>
		<tr>
			<td colspan="2"><input type="submit" name="editproject" value="Mentés"></td>
		</tr>
	</table>
</form>

<table class="box" style="width: 500px;">
	<tr>
		<td colspan="3" class="title">
			Fejlesztők
			<span>
				<form action="" method="post">
					<select name="developer" style="display: inline;">
						<option value="">Fejlesztő kiválasztása</option>
						<?php
							for($i=0; $i<count($developers); $i++){
								print "<option value=\"".$developers[$i][0]."\">".$developers[$i][1]."</option>";
							}
						?>
					</select>
					<input type="submit" name="adddeveloper" value="Hozzáadás">
				</form>
			</span>
		</td>
	</tr>
	<?php
		if($workers != null){
			for($i=0; $i<count($workers); $i++){
				print "
					<tr>
						<td>".($i+1)."</td>
						<td>".$workers[$i][1]."</td>
						<td>
							<form action=\"\" method=\"post\">
								<input type=\"hidden\" name=\"developer\" value=\"".$workers[$i][0]."\">
								<input type=\"submit\" name=\"deldeveloper\" value=\"Törlés\">
							</form>
						</td>
					</tr>
				";
			}
		}
		else{
			print "
				<tr>
					<td colspan=\"3\" class=\"empty\">Nincsenek fejlesztők hozzárendelve a projekthez.</td>
				</tr>
			";
		}
	?>
</table>